package com.bianguo.android.baidumapdemo.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.baidu.mapapi.walknavi.WalkNavigateHelper;
import com.baidu.mapapi.walknavi.adapter.IWNaviStatusListener;
import com.baidu.navisdk.adapter.BNRouteGuideManager;
import com.baidu.platform.comapi.walknavi.WalkNaviModeSwitchListener;
import com.bianguo.android.baidumapdemo.utils.MLog;

public class WNaviGuideActivity extends AppCompatActivity {

    private WalkNavigateHelper mNaviHelper;
    private BNRouteGuideManager guideManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 获取诱导页面地图展示View
        guideManager = BNRouteGuideManager.getInstance();
        mNaviHelper = WalkNavigateHelper.getInstance();
        View view = BNRouteGuideManager.getInstance().onCreate(this, new BNRouteGuideManager.OnNavigationListener() {
            @Override
            public void onNaviGuideEnd() {
                finish();
            }

            @Override
            public void notifyOtherAction(int actionType, int arg1, int arg2, Object obj) {

            }
        });
        if (view != null) {
            setContentView(view);
        }
//        mNaviHelper.setWalkNaviStatusListener(new IWNaviStatusListener() {
//            @Override
//            public void onWalkNaviModeChange(int mode, WalkNaviModeSwitchListener listener) {
//                MLog.mLog("onWalkNaviModeChange : " + mode);
//                mNaviHelper.switchWalkNaviMode(WNaviGuideActivity.this, mode, listener);
//            }
//
//            @Override
//            public void onNaviExit() {
//                MLog.mLog("onNaviExit");
//            }
//        });
//        mNaviHelper.startWalkNavi(this);
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        guideManager.onBackPressed(false);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
//        mNaviHelper.quit();
        guideManager.onDestroy();
    }

    @Override
    protected void onStop() {
        super.onStop();
        guideManager.onStop();
    }

    @Override
    protected void onResume() {
        super.onResume();
//        mNaviHelper.resume();
        guideManager.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
//        mNaviHelper.pause();
        guideManager.onPause();
    }
}
